<template>
  <div>
    <h1>Count</h1>

    <!-- 计算属性 让插值语法更方便阅读 -->
    <p>我的count的值是{{ count }}</p>
    <p>我的num的值是{{ num }}</p>
    <!-- <button @click="$store.commit('increament')">累加count的值</button>
    <button @click="$store.commit('increamentN',{n:3})">count的值加n</button> -->
    <button @click="increament">累加count的值</button>
    <button @click="increamentN({ n: 3 })">count的值加n</button>
    <button @click="incrementWait">过1s累加count的值</button>
    <button @click="increamentN({ n: 3 })">count的值过1s加n</button>
  </div>
</template>

<script>
import { mapActions, mapMutations, mapState } from "vuex";

export default {
  name: "Count",

  computed: {
    ...mapState(["count", "num"]),
  },
  methods: {
    ...mapMutations(["increament", "increamentN"]),
    ...mapActions(["incrementWait"])
  },
};
</script>

<style scoped></style>
